/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package others.business;

import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import others.DAO.ExecuteStatementDAO;

/**
 *
 * @author Javier
 */
public class TerminalBusiness {

    public TerminalBusiness() {
    }
    
    public String doStatement(String sql){
        StringTokenizer st = new StringTokenizer(sql,"\\;");
        List<String> statements = new ArrayList<>();
        List<String> results = new ArrayList<>();
        String devuelta = "";
        System.out.println("numero de tokens :" +st.countTokens());
        while(st.hasMoreTokens()){
            String token = st.nextToken();
            System.out.println("token "+ token);
            statements.add(token);
            results.add(new ExecuteStatementDAO().doStatement(token));
        }
        for(int i = 0; i<statements.size();i++){
            devuelta = devuelta + statements.get(i) +": \n"
                    + results.get(i)+"  \n"
                    +" ";
        }
        System.out.println(devuelta);
        return devuelta;
        
    }
}
